﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace BL
{
    public static class Log
    {
        //TODO: Implementar o Log de erro nas classes e metodos necessários
        public static bool insertLog(string error, string metodo, string classe)
        {
            try
            {

                string nomeArch;
                //TODO: alterar nome da pasta!
                nomeArch = Properties.Settings.Default.CaminhoLog +System.DateTime.Today.Day + "-" + System.DateTime.Today.Month + "-" + System.DateTime.Today.Year + "_Log.txt";
                //gravação em txt



                FileStream arqtxt = new FileStream(nomeArch, FileMode.Append, FileAccess.Write);

                StreamWriter streamWriter = new StreamWriter(arqtxt);

                streamWriter.WriteLine("");
                streamWriter.WriteLine(System.DateTime.Now + " : ");
                streamWriter.WriteLine("");
                streamWriter.WriteLine("Erro na Classe: " + classe + " no metodo: " + metodo);
                streamWriter.WriteLine("");
                streamWriter.WriteLine("Erro: " + error);
                streamWriter.WriteLine("--------------------------------------------------------------------------------------------------");

                streamWriter.Close();
                return true;
            }
            catch
            {
                return false;
            }
        }
       

    }



}
